#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5+1000;
typedef int LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
vector<LL>g[maxn];
LL col[maxn];
int main(void){
   LL n,m;n=read();m=read();
   for(LL i=1;i<=m;i++){
      LL u,v;u=read();v=read();
      g[u].push_back(v);
      g[v].push_back(u);
   }
   if(g[1].size()==0){
     printf("-1\n");
     return 0;
   }
   LL one=1;
   col[1]=1;
   LL two=g[1][0];
   col[two]=2;
   LL three=0;
   for(LL i=1;i<=n;i++){
      if(i==one||i==two) continue;
      bool f1=0;bool f2=0;
      for(LL j=0;j<g[i].size();j++){
         LL v=g[i][j];
         if(v==one) f1=1;
         if(v==two) f2=1;
      }
      if(f1&&f2){
         three=i;
         col[three]=3;
         break;
      }
   }
   if(!three){
     printf("-1\n");return 0;
   }
   for(LL i=1;i<=n;i++){
      LL f1=0;LL f2=0;LL f3=0;
      for(LL j=0;j<g[i].size();j++){
          LL v=g[i][j];
          if(v==one) f1++;
          if(v==two) f2++;
          if(v==three) f3++;
      }
      if(f1+f2+f3!=2){
         printf("-1\n");
         return 0;
      }
      if(f1&&f2&&!f3) col[i]=3;
      if(f1&&f3&&!f2) col[i]=2;
      if(f2&&f3&&!f1) col[i]=1;
   }
   map<LL,LL>map1;
   for(LL i=1;i<=n;i++){
      map1[col[i]]++;
   }
   LL num1=map1[1];LL num2=map1[2];LL num3=map1[3];
   if(num1*num2+num2*num3+num3*num1!=m){
     printf("-1\n");return 0;
   }
   else{
    for(LL i=1;i<=n;i++){
       for(LL j=0;j<g[i].size();j++){
          if(col[g[i][j]]==col[i]){
            printf("-1");
            return 0;
          }
       }
    }
    for(LL i=1;i<=n;i++){
        printf("%d ",col[i]);
    }
    printf("\n");
   }
   return 0;
}
